<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width"/>
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>新技术讲座</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/main.css" />
    <link rel="stylesheet" type="text/css" href="../../css/myDevelop.css" />
</head>
<body>
  <div id="header">
      <div id="back"></div>
      <h3>新技术讲座</h3>
  </div>
  <div id="all">
    <div id="lectures">
      <!-- <div class="item">
          <div class="title">新技术讲座一</div>
          <div class="status end">已结束</div>
          <div class="content">
            <div><span>讲座介绍：</span><span>xxxxxx</span></div>
            <div><span>讲座讲师：</span><span>xxxxx</span></div>
            <div><span>课程时间：</span><span>2018-12-13 19:12:12</span></div>
            <div><span>学生主体：</span><span>学生</span></div>
          </div>
          <div class="tools"><button class="btn btn-g">查看安排</button></div>
      </div> -->
      <!-- <div class="item">
          <div class="title">新技术讲座二</div>
          <div class="status doing">进行中</div>
          <div class="content">
            <div><span>讲座介绍：</span><span>xxxxxx</span></div>
            <div><span>讲座讲师：</span><span>xxxxx</span></div>
            <div><span>课程时间：</span><span>2018-12-13 19:12:12</span></div>
            <div><span>学生主体：</span><span>学生</span></div>
          </div>
          <div class="tools"><button class="btn btn-g">查看安排</button></div>
      </div> -->
    </div>
  </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery.js"></script>
<script type="text/javascript">
apiready=function(){
  var flag=$api.getStorage('flag');
  var aid=$api.getStorage('aid');
  var jwt=$api.getStorage('jwt');
  var nowTime=Date.parse(new Date());
  //查询讲座列表
  api.ajax({
    url: 'http://47.104.170.122/v1/portal/training/student/app/lecture?token='+jwt,
    method: 'GET',
    headers: {
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Allow-Headers": "Authorization",
      "Content-Type" : 'application/json; charset=utf-8'
    }
  }, function(ret, err) {
    if(ret.code==0){
      var json=ret.data;
      $.each(json,function(i,val){
        introduction=json[i].introduction;
        presenter=json[i].presenter;
        title=json[i].title;
        if(json[i].endTime-nowTime>0){
            status='进行中'
            statusClass='doing'
        }else{
            status='已结束'
            statusClass='end'
        }
        startTime=getLocalTime(json[i].startTime);
        endTime=getLocalTime(json[i].endTime);
        time=startTime+'-'+endTime;
        id=json[i].id;
        var template=`<div class="item">
            <div class="title">`+title+`</div>
            <div class="status `+statusClass+`">`+status+`</div>
            <div class="content">
              <div><span>讲座介绍：</span><span>`+introduction+`</span></div>
              <div><span>讲座讲师：</span><span>`+presenter+`</span></div>
              <div><span>课程时间：</span><span>`+time+`</span></div>
              <div><span>学生主体：</span><span>学生</span></div>
            </div>
            <div class="tools" id="`+id+`"><button class="btn btn-g">查看安排</button></div>
        </div>`;
        $("#lectures").append(template)
      })
    }
  });
  $("#lectures").on("click",".tools",function(){
     var status=$(this).parent().find(".status").html();
     var thisId=$(this).attr("id");
     api.openWin({
        name: 'lectures_detail',
        url: 'lectures_detail.html',
        pageParam: {
            status: status,
            title:title,
            introduction:introduction,
            presenter:presenter,
            time:time,
            thisId:thisId
        }
    });
  })
}
//jquery
$(function(){
  back();
})
</script>
<script type="text/javascript" src="../../script/main.js"></script>
</html>
